home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 November: Tool Chest / Dev.CD Nov 96 TC / Dev.CD Nov 96 TC.toast / Sample Code / Snippets / Memory / SimpleInit / SimpleInit.c next >
Encoding:
C/C++ Source or Header  |  1994-12-21  |  1.4 KB  |  47 lines  |  [TEXT/MPS ]

  1. /*****************************************************************************************
  2.      Snippet:            SimpleInit
  3.      
  4.      Description:        This snippet demonstrates the writing of a simple init which
  5.                         attempts to allocate a 1 megabyte and then a 2 megabyte handle
  6.                         in the System heap. Please note the 'sysz' resource in the init
  7.                         which is necessary in order to allocate the memory (see Inside 
  8.                         Macintosh Memory page 2-13; NOTE: the 'sysz' resource *is* in 
  9.                         fact still required under System 7 contrary to the statement in 
  10.                         Inside Macintosh Memory)
  11.                          
  12.      Programmer:            Kevin Mellander
  13.      Organization:        Apple Computer, Inc.
  14.      Department            Developer Technical Support, DTS
  15.      Language/Envir.        MPW C version 3.3.1
  16.      Date Created        12/12/94                              
  17.  
  18.  *****************************************************************************************/
  19. #include <Memory.h>
  20. #include <Types.h>
  21.  
  22. #pragma segment Main
  23. main()
  24. {
  25.     Handle    mySysHandle = nil;
  26.     
  27.     mySysHandle = NewHandleSys(1000000);
  28.     
  29.     if (mySysHandle == nil)
  30.         DebugStr("\p the 1,000,000 byte call to mySysHandle failed");
  31.     else
  32.         DebugStr("\p the 1,000,000 byte call to mySysHandle succeeded");
  33.  
  34.     if (mySysHandle)
  35.         DisposeHandle(mySysHandle);
  36.     
  37.     mySysHandle = NewHandleSys(2000000);
  38.     
  39.     if (mySysHandle == nil)
  40.         DebugStr("\p the 2,000,000 byte call to mySysHandle failed");
  41.     else
  42.         DebugStr("\p the 2,000,000 byte call to mySysHandle succeeded");
  43.     
  44.     if (mySysHandle)
  45.         DisposeHandle(mySysHandle);
  46.     
  47. }